Cope with serial and usb packets being different size.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 14 Sep 2004 14:30:38 +0000 (14:30 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 14 Sep 2004 14:30:38 +0000 (14:30 +0000)
gpsbabel/jeeps/gpsmem.c

index 5635adbc061403dd40de34e5cb6bd74de9882551..8712fecdc0f329be64beb087c995789baabf75f0 100644 (file)
 ** Boston, MA  02111-1307, USA.
 ********************************************************************/
 #include "gps.h"
+#include "garminusb.h"
 #include <stdlib.h>
 #include <errno.h>
 #include <stdio.h>
 #include <limits.h>
 
-
 /* @func GPS_Packet_New ***********************************************
 **
 ** Packet constructor
 GPS_PPacket GPS_Packet_New(void)
 {
     GPS_PPacket ret;
-    
-    if(!(ret=(GPS_PPacket )malloc(sizeof(GPS_OPacket))))
+    int hdr_size = gps_is_usb  ? sizeof(garmin_usb_packet) : sizeof sizeof(GPS_OPacket) ;
+    if(!(ret=(GPS_PPacket )malloc(hdr_size)))
     {
        perror("malloc");
        fprintf(stderr,"GPS_Packet_New: Insufficient memory");
        fflush(stderr);
        return NULL;
     }
-
     if(!(ret->data = (UC *)malloc(MAX_GPS_PACKET_SIZE*sizeof(UC))))
     {
        perror("malloc");